function keydown(e)
{
    var e = e||event;
    var currKey = e.keyCode||e.which||e.charCode;
    if(currKey == 13)
    {
        checkLogin();
    }
}

function checkLogin(){
    var username = $("input[name='name']").val();
    var password = $("input[name='password']").val();

    if ($.trim(username) == "" ||　$.trim(password) == "") {
        return false;
    }

    $.ajax({    
        url:ctx + '/login',
        data: {
            name : username,
            password : password
        },
        type:'post',   
        success:function(data) {
            if (data.result_code=='SUC') {
                window.location.href=ctx + "/index";
            }else{
            	layer.msg('账号和密码错误，登录失败！');
            }
        },    
        error : function() {layer.msg('账号和密码错误，登录失败！');}    
    });
}